package presenter;


import java.util.Observer;

import interfaces.IMessgeInterface;
import responsitory.SystemMessgePresponsitory;
import util.volley.ICompleteListener;
import util.volley.ResultEntity;

/**
 * Created by itboye on 2016/12/5.
 */

public class SystemMessgeAPresenter extends  BasePresenter implements IMessgeInterface<String> {

    /**
     * 系统消息
     */
    public static final String SystemMessge_success = UserPresenter.class.getName()
            + "_SystemMessge_success";
    public static final String SystemMessge_fail = UserPresenter.class.getName()
            + "_SystemMessge_fail";

    /**
     * 维修消息
     */
    public static final String RepairMessge_success = UserPresenter.class.getName()
            + "_RepairMessge_success";
    public static final String RepairMessge_fail = UserPresenter.class.getName()
            + "_RepairMessge_fail";

    /**
     * 维修记录
     */
    public static final String WeiXiuJilu_success = UserPresenter.class.getName()+ "_WeiXiuJilu_success";
    public static final String WeiXiuJilu_fail = UserPresenter.class.getName()+ "_WeiXiuJilu_fail";


    /**
     * 提现申请
     */
    public static final String Tixian_success = SystemMessgeAPresenter.class.getName()
            + "_Tixian_success";
    public static final String Tixian_fail = SystemMessgeAPresenter.class.getName()
            + "_Tixian_fail";

    /**
     * 提现申请
     */
    public static final String Yue_success = SystemMessgeAPresenter.class.getName()
            + "_Yue_success";
    public static final String Yue_fail = SystemMessgeAPresenter.class.getName()
            + "_Yue_fail";

    /**
     * 设置支付密码
     */
    public static final String Wallet_success = SystemMessgeAPresenter.class.getName()
            + "_Wallet_success";
    public static final String Wallet_fail = SystemMessgeAPresenter.class.getName()
            + "_Wallet_fail";


    /**
     * 记得支付密码设置支付密码
     */
    public static final String Remember_success = SystemMessgeAPresenter.class.getName()
            + "_Remember_success";
    public static final String Remember_fail = SystemMessgeAPresenter.class.getName()

            + "_Remember_fail";
    /**
     * 支持账号提现类型
     */
    public static final String BangdingType_success = SystemMessgeAPresenter.class.getName()+ "_BangdingType_success";
    public static final String BangdingType_fail = SystemMessgeAPresenter.class.getName()+ "_BangdingType_fail";


    /**
     * 支持账号提现类型
     */
    public static final String PWD_success = SystemMessgeAPresenter.class.getName()+ "_PWD_success";
    public static final String PWD_fail = SystemMessgeAPresenter.class.getName()+ "_PWD_fail";

    public SystemMessgeAPresenter(Observer observer) {
        super(observer);
    }

    /**
     * 系统消息
     * @param uid
     * @param type
     */
    @Override
    public void onSystemMessge(String uid, String type) {
        IMessgeInterface<String> ShopIngMal=new SystemMessgePresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(SystemMessge_success);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(SystemMessge_fail);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);

            }
        });
        ShopIngMal.onSystemMessge(uid,type);
    }

    /**
     * 维修消息
     * @param uid
     * @param id
     */
    @Override
    public void onRepairMessge(String uid, String id) {
        IMessgeInterface<String> ShopIngMal=new SystemMessgePresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(RepairMessge_success);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(RepairMessge_fail);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);

            }
        });
        ShopIngMal.onSystemMessge(uid,id);
    }

    @Override
    public void onMoneySys(String uid, String account_id, String money) {
        IMessgeInterface<String> ShopIngMal=new SystemMessgePresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(Tixian_success);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(Tixian_fail);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);

            }
        });
        ShopIngMal.onMoneySys(uid,account_id,money);
    }

    @Override
    public void onWallet(String uid,  String news) {
        IMessgeInterface<String> ShopIngMal=new SystemMessgePresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(Wallet_success);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(Wallet_fail);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);

            }
        });
        ShopIngMal.onWallet(uid,news);

    }

    @Override
    public void onMoney(String uid) {
        IMessgeInterface<String> ShopIngMal=new SystemMessgePresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(Yue_success);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(Yue_fail);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);

            }
        });
        ShopIngMal.onMoney(uid);
    }

    @Override
    public void onRememberPay(String uid, String old, String news) {
        IMessgeInterface<String> ShopIngMal=new SystemMessgePresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(Remember_success);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(Remember_fail);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);

            }
        });
        ShopIngMal.onRememberPay(uid,old,news);
    }
    @Override
    public void onWeiXiuJiLu(String uid, String id,String current_page,String per_page) {
        IMessgeInterface<String> ShopIngMal=new SystemMessgePresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(WeiXiuJilu_success);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(WeiXiuJilu_fail);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);

            }
        });
        ShopIngMal.onWeiXiuJiLu(uid,id,current_page,per_page);
    }

    @Override
    public void onBangDinType() {
        IMessgeInterface<String> ShopIngMal=new SystemMessgePresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(BangdingType_success);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(BangdingType_fail);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);

            }
        });
        ShopIngMal.onBangDinType();
    }

    @Override
    public void onByWalletCheckSecret(String uid, String secret) {
        IMessgeInterface<String> ShopIngMal=new SystemMessgePresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(PWD_success);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(PWD_fail);
                SystemMessgeAPresenter.this.setChanged();
                SystemMessgeAPresenter.this.notifyObservers(result);

            }
        });
        ShopIngMal.onBangDinType();
    }
}
